import zope.interface

from Acquisition import aq_inner,aq_parent

from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

from plone.memoize.view import memoize, memoize_contextless

from meercat.ui.plone.interfaces import IMeercatConnectionManager



class BaseView(BrowserView):
    def __init__(self, context, request):
        super(BrowserView,self).__init__(context, request)
        self.manager = aq_inner(self.context).getMeercatManager()
    
    @memoize_contextless
    def portal_url(self):
        return aq_inner(self.context).absolute_url()
    
    @memoize
    def getSolrConnection(self):
        return self.manager.getSolrConnection()
    
    @memoize
    def getRestConnection(self):
        return self.manager.getRestConnection()
    
    def query(self,**params):
        return self.manager.query(**params)